package compilador.lexico;

import java.util.ArrayList;
import java.util.List;
//import java.util.Vector;

/**
 * @author  Matias
 */
public class AnalizadorLexico {

	/**
	 * @uml.property  name="tS"
	 * @uml.associationEnd  
	 */
	TablaSimbolos TS;
	/**
	 * @uml.property  name="l"
	 * @uml.associationEnd  
	 */
	LectorToken L;
	/**
	 * @uml.property  name="errores"
	 */
	List<ErrorComp> Errores ;
	
	public AnalizadorLexico(String code){
		TS = new TablaSimbolos();
		L = new LectorToken(TS,code);
		TS.agregarSimbolo("Palabra reservada", "If");
		TS.agregarSimbolo("Palabra reservada", "else");
		TS.agregarSimbolo("Palabra reservada", "for");
		TS.agregarSimbolo("Palabra reservada", "print");
		TS.agregarSimbolo("Palabra reservada", "uint");
		TS.agregarSimbolo("Palabra reservada", "ulong");
	}
	
	/**
	 * @return
	 * @uml.property  name="errores"
	 */
	public List<ErrorComp> getErrores(){
		return L.getErrores();
	}
	
	public Token getNextToken(){
		if (L.HasMoreElements())
			return L.getToken();
		else
			return null;
	}
	
	public TablaSimbolos getTablaSimbolos(){
		return TS;
	}
	
	public List<Token> getListToken(){
		Token t;
		List<Token> lstTokens = new ArrayList<Token>();
		while ((t = L.getToken()) != null){
			lstTokens.add(t);
		}
		return lstTokens;
	}
	
}
